﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using PrattParsing;

using sapphirelang.AST;
using sapphirelang.AST.Stmts;
using sapphirelang.AST.Patterns;

namespace sapphirelang.Parsing
{
    class StmtParser : Parser<Stmt>
    {
        ExprParser exprParser;

        public StmtParser(IScanner scanner)
            : base(scanner)
        {
            this.exprParser = new ExprParser(scanner);

            TokenType.Init();

            ParseContext<Stmt> rules = new ParseContext<Stmt>();

            // def-method
            // loop
            // - while, for

            // break;
            // next;
            // redo;
            // return {expr};
            // func name(pat, pat, ...) = {expr}
            // func name(pat, pat, ...) {BlockExpr}
            // while {expr} 
            // {expr};

            // special EOF parselet, to signify end of parsing
            rules.prefix(Token.EOF_TYPE, lambda((parser, token) => null));

            Grammar<Stmt> grammar = new Grammar<Stmt>();
            grammar["base"] = rules;

            SetGrammar(grammar);
        }
    }
}
